from driver import GPIO


relay_1=GPIO()
relay_1.open("relay1")

relay_2=GPIO()
relay_2.open("relay2")


def relay_ctl(port,state):
    if port==1:
        relay_1.write(state)
        print('relay port1,state={}'.format(relay_1.read()))
    elif port==2:
        relay_2.write(state) 
        print('relay port2,state={}'.format(relay_2.read()))  

    elif port==3:
        relay_1.write(state)
        relay_2.write(state) 
        print('relay port1&port2,state={}-{}'.format(relay_1.read(),relay_2.read()))
    
def get_relay_state(port):
    if port==1:
        return relay_1.read()
    elif port==2:
        return relay_2.read()    
    elif port ==3:
        return  relay_1.read(),relay_2.read()    
 
